// pages/guest/guest.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        picker:{
            arr: [1,2,3,4,5,6,7],
            index: 0
        }
    },
    pickerChange(e) {
        this.setData({
            'picker.index': e.detail.value
        })
    },

    changePhone(e){
        this.checkPhone(e.detail.value);
        // console.log(e);
    },
    changeName(e){
        this.checkName(e.detail.value);
        // console.log(e);
    },
    checkName(data) {  
        const reg = /^[\u4e00-\u9fa5]/;
        return this.check(data,reg,'姓名有误')
    },

    checkPhone(data) {  
        const reg = /^((13)|(15)|(18))\d(9)$/;
        return this.check(data,reg,'手机号码有误')
    },

    check(data, reg, errMsg) {
        if(!reg.test(data)) {
            wx.showToast({
              title: errMsg,
              icon: 'none',
              duration: 1500
            })
            return false;
        }
        return true;
    }
})